import React from 'react';
import { connect } from 'react-redux';
import setClientHeight from 'Actions/webAction';
import './index.scss';

class PageContainer extends React.PureComponent {
  componentDidMount() {
    const { clientHeight, dispatch } = this.props;
    if (clientHeight < document.documentElement.clientHeight) {
      dispatch(setClientHeight(document.documentElement.clientHeight));
    }
  }
  render() {
    const { clientHeight, children } = this.props;
    return (
      <div
        className="page-container"
        style={{ height: clientHeight }}
      >
        { children }
      </div>
    );
  }
}

function mapStateToProps(state) {
  return {
    ...state.webReducer,
  };
}

export default connect(mapStateToProps)(PageContainer);
